<template>
  <div class="app-container">
    <el-form :inline="true" :model="form">
      <el-form-item>
        <el-button type="success">添加人员</el-button>
      </el-form-item>
      <el-form-item label="姓名">
        <el-input v-model="form.realName"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getMemberList">搜索</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="listLoading" :data="tableData" fit highlight-current-row>
      <el-table-column prop="id" label="序号" width="100px"></el-table-column>
      <el-table-column prop="realName" label="姓名" width="100px"></el-table-column>
      <el-table-column prop="teamRole" label="对内身份"></el-table-column>
      <el-table-column prop="" label="所属组"></el-table-column>
      <el-table-column prop="" label="组内职务"></el-table-column>
      <el-table-column prop="gender" label="性别"></el-table-column>
      <el-table-column prop="phone" label="手机号"></el-table-column>
      <el-table-column prop="politics" label="政治面貌"></el-table-column>
      <el-table-column label="操作" width="300px">
        <template slot-scope="scope">
          <el-button type="primary" size="mini">详情</el-button>
          <el-button type="primary" size="mini">编辑</el-button>
          <el-button type="success" size="mini">组内身份</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="form.page"
      :page-sizes="[5, 10, 20, 40]" :page-size="form.pageSize" layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
import { memberList } from '@/api/member';
export default {
  data() {
    return {
      listLoading: false,
      form: {
        name: '',
        nickname: '',
        teamRole: '',
        page: 1,
        pageSize: 5,
      },
      tableData: [],
      total: 0,
    }
  },
  methods: {
    getMemberList() {
      memberList(this.form).then(res => {
        console.log(res);
        this.tableData = res.data.records
        this.total = res.data.total
      })
    },
    handleSizeChange(val) {
      this.form.page = 1// 重置页码
      this.form.pageSize = val;
      this.getMemberList()
    },
    handleCurrentChange(val) {
      this.form.page = val;
      this.getMemberList()
    },
  },
  mounted() {
    this.getMemberList();
  }

}
</script>
